package com.acwing.partition20;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/1/18 20:04
 */
public class AC1929镜子田地 {

    private static final int N = 1010;
    private static final int[] dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
    private static String[] g = new String[N];
    private static int n, m;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        for (int i = 0; i < n; i++) g[i] = reader.readLine();
        //从周边4个方向开始射入，用 0 1 2 3 分别表示射入方向 ↑ → ↓ ←，当镜子是 / 时，方向 0->1,3->2,2->3,1->0，当镜子是 \ 时，方向 0->3,1->2,2->1,3->2
        int ans = 0;
        for (int i = 0; i < m; i++) {
            ans = Math.max(ans, dfs(0, i, 2));
            ans = Math.max(ans, dfs(n - 1, i, 0));
        }
        for (int i = 0; i < n; i++) {
            ans = Math.max(ans, dfs(i, 0, 1));
            ans = Math.max(ans, dfs(i, m - 1, 3));
        }
        writer.write(ans + "\n");
        writer.flush();
    }

    private static int dfs(int x, int y, int dir) {
        if (x < 0 || x >= n || y < 0 ||y >= m) return 0;
        if (g[x].charAt(y) == '/') dir ^= 1;
        else dir ^= 3;
        return dfs(x + dx[dir], y + dy[dir], dir) + 1;
    }
}
